package com.my.controller;


import com.my.bean.*;
import com.my.service.LossService;
import com.my.util.SessionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * <p>
 * 物品损耗统计 前端控制器
 * </p>
 *
 * @author 崔倩倩
 * @since 2018-08-26
 */
@Controller
@RequestMapping("/loss")
public class LossController {

    @Autowired
    LossService lossService;

    //跳转
    @RequestMapping("main.html")
    public String  main( ){
        return  "loss";
    }
    @RequestMapping("loss_add.html")
    public String  loss_add( ){
        return  "/Alert/loss_add";
    }


    //查询列表表格
    @RequestMapping("/list")
    @ResponseBody
    public ResultPage<Loss> list(VoPage voPage, Loss loss, HttpSession session) {
        boolean admin=false;
        //如果事超级管理员  即可查看所有的房间  判断是否为超级管理员
        if(SessionUtil.getSessionUser(session).getRoles().getRoleValue().equals("9f77d5a8-75c6-4d06-adf9-a37e727d491a")){
            admin=true;
        }
        Long areaid = ((User)session.getAttribute("user")).getAreaId();
        return  lossService.selectMyPage(voPage,loss,areaid,admin);
    }

}

